package com.example.proxybean.proxy;

import com.example.proxybean.interceptor.MyInterceptor;

public class ProxyBean {

    Object target;

    MyInterceptor interceptor;

    public static ProxyBean generateProxyBean(Object target,MyInterceptor interceptor){
        ProxyBean bean = new ProxyBean();
        bean.target=target;
        bean.interceptor=interceptor;
        return bean;
    }

    public void invoke(){

        try {
            interceptor.around(target,target.getClass().getMethod("hello"),new Object[0]);
        } catch (NoSuchMethodException e) {
            throw new RuntimeException(e);
        }

    }

}
